﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

using System.Runtime.InteropServices;
using Dal;
using HisVBEncrypt;



namespace TLCApp
{
    public partial class Rent00 : Form
    {
        //protected override bool ProcessCmdKey(ref System.Windows.Forms.Message msg, System.Windows.Forms.Keys keyData)
        //{
        //    switch (keyData)
        //    {
        //        case Keys.Enter:
        //            SendKeys.Send("{TAB}");
        //            break;
        //        case Keys.Escape:
        //            this.DialogResult = DialogResult.Cancel;
        //            break;
        //    }
        //    return base.ProcessCmdKey(ref msg, keyData);

        //}
        public string strstutus = "";
        public Rent00()
        {
            InitializeComponent();
        }

        

        private void btnCancel_Click(object sender, EventArgs e)
        {
            this.DialogResult = DialogResult.No;
      
        }
     
   
        private void OK_Click(object sender, EventArgs e)
        {
            //txtUsernameTextBox.Select();
            //bool d = PublicFunc.Func.Cls_Func.DeleFiles(Environment.GetEnvironmentVariable("TEMP"), "rpt");
            //OutDoctorBiz.Cls_LoginBiz LogBiz = new Cls_LoginBiz();
          
            try
            {


                DataSet ds = Dal.sys.CheckPassWord(this.txtUsernameTextBox.Text.Trim(), HisVBEncrypt.Encrypt.Encrypt(this.txtPWD.Text.Trim()));

                if (ds != null && ds.Tables[0].Rows[0]["RST"].ToString().ToUpper() == "T")
                {
                    DataTable dt = ds.Tables[1];
                    TLCApp.pulic.UserIfo.userId = dt.Rows[0]["Employee_id"].ToString();
                    TLCApp.pulic.UserIfo.userName = dt.Rows[0]["Employee_MC"].ToString();
                    TLCApp.pulic.UserIfo.userDepId = dt.Rows[0]["deptcode"].ToString();
                    TLCApp.pulic.UserIfo.userDepName = dt.Rows[0]["cmn_dept_mc"].ToString();
                    TLCApp.pulic.UserIfo.userDepType = dt.Rows[0]["cmn_dept_type"].ToString();
                    TLCApp.pulic.UserIfo.userRote = dt.Rows[0]["role_id"].ToString();
                  // TLCApp.pulic.Cls_Popup.MsgWarnBox(ds.Tables[0].Rows[0]["MSG"].ToString());
                    strstutus = TLCApp.pulic.UserIfo.userName + '[' + TLCApp.pulic.UserIfo.userId + ']' + '[' + TLCApp.pulic.UserIfo.userDepName + ']';
                    loadData();
                    TLCApp.pulic.UserIfo .rptname = System.Configuration.ConfigurationSettings.AppSettings["rptname"].ToString();  
                    this.DialogResult = DialogResult.Yes;
                
                }
                else
                {

                    TLCApp.pulic.Cls_Popup.MsgWarnBox(ds.Tables[0].Rows[0]["MSG"].ToString());
                }

            }
            catch (Exception ex)
            {
                TLCApp.pulic.WriteLog.WriteLoginf(ex.ToString());
            }
        }
        /// <summary>
        /// 登陆加载信息
        /// </summary>
        void loadData()
        {
            TLCApp.pulic.UserIfo.dsBasedata=Dal.sys.GetBasedata();
        }

        //调用Kernel32.DLL
        [DllImport("Kernel32.dll")]
        public static extern void GetLocalTime(SystemTime st);
        [DllImport("Kernel32.dll")]
        public static extern void SetLocalTime(SystemTime st);

        [StructLayout(LayoutKind.Sequential)]
        public class SystemTime
        {
            public ushort wYear;
            public ushort wMonth;
            public ushort wDayOfWeek;
            public ushort wDay;
            public ushort Whour;
            public ushort wMinute;
            public ushort wSecond;
            public ushort wMilliseconds;
        }


        void setApTimer()
        {
            try
            {
                //OutDoctorBiz.Cls_LoginBiz LogBiz = new Cls_LoginBiz();
               // string strdate = LogBiz.GetSysdate();
                //if (strdate != "")
                //{

                //    SystemTime stServer = new SystemTime();
                //    stServer.wYear = (ushort)Convert.ToDateTime(strdate).Year;
                //    stServer.wMonth = (ushort)Convert.ToDateTime(strdate).Month;
                //    stServer.wDay = (ushort)Convert.ToDateTime(strdate).Day;
                //    stServer.Whour = (ushort)Convert.ToDateTime(strdate).Hour;
                //    stServer.wMinute = (ushort)Convert.ToDateTime(strdate).Minute;
                //    stServer.wSecond = (ushort)Convert.ToDateTime(strdate).Second;

                //    SetLocalTime(stServer);
                //}
            }
            catch (Exception ex)
            {

            }



        }
        private void Cancel_Click(object sender, EventArgs e)
        {
            this.DialogResult = DialogResult.Cancel;
            this.Close();
        }

        private void Rent00_Load(object sender, EventArgs e)
        {

        }

        private void btnRsg_Click(object sender, EventArgs e)
        {

        }
       
    }
}
